package com.hongye.common.exception;

import com.hongye.common.exception.code.ServiceExceptionCode;
import lombok.Data;

import java.util.Map;

/*
    凤兮凤兮归故乡，遨游千里求其凰
    2021/7/16
*/
@Data//e ke sai p shen
public class ServiceException extends RuntimeException {

    private String code; //错误码

    private String msg; //错误信息

    private Map data; //返回数据

    public ServiceException(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ServiceException(String code, String msg, Map data) {
        this.code = code;
        this.msg = msg;
        if (data != null){
            this.data = data;
        }
    }
    public ServiceException(ServiceExceptionCode serviceExceptionCode) {
        this.code=serviceExceptionCode.getCode();
        this.msg = serviceExceptionCode.getName();
    }
}
